﻿using System.Collections.Generic;

namespace Common
{
    /// <summary>
    /// Name - DailyEntryViewModel.cs
    /// Description - Encapsulates data from the user interface for the business layer
    /// Programmer - Matthew Mitchell
    /// Date coded - 11/27/2011
    /// Arguments - None
    /// Variables - None
    /// Files accessed by this code artifact - None
    /// Files changed by this code artifact - None
    /// I/O - None
    /// Error Handling - None
    /// Modifications -
    ///     1.0 - Initial coding
    /// Known Faults -
    ///     1.0 - None known
    /// </summary>
    public class DailyEntryViewModel
    {
        private List<TrackableHealthParameter> changedHealthParameters;

        /// <summary>
        /// Gets or sets the health parameters.
        /// </summary>
        /// <value>
        /// The health parameters.
        /// </value>
        public IEnumerable<TrackableHealthParameter> HealthParameters { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="DailyEntryViewModel"/> class.
        /// </summary>
        public DailyEntryViewModel()
        {
            changedHealthParameters = new List<TrackableHealthParameter>();
        }

        /// <summary>
        /// Updates the health parameter.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="dailyValue">The daily value.</param>
        public void UpdateHealthParameter(int id, double dailyValue)
        {
            foreach (var trackableHealthParameter in HealthParameters)
            {
                if (trackableHealthParameter.ID == id)
                {
                    if (trackableHealthParameter.Value != dailyValue)
                    {
                        trackableHealthParameter.Value = dailyValue;

                        changedHealthParameters.Add(trackableHealthParameter);
                    }
                }
            }
        }

        /// <summary>
        /// Exposes changed health parameters.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<TrackableHealthParameter> ChangedHealthParameters()
        {
            return changedHealthParameters;
        }
    }
}
